-
Notifications
You must be signed in to change notification settings - Fork 190
Conversation
5445250
to
c230ca9
Compare
This isn't how I think it should be done. We should update FormFile to have a name property on it. Make it lazy there. |
c230ca9
to
feb80f0
Compare
@davidfowl Hence my "These names should probably be cached somewhere. Anyone opposed to exposing a |
@khellang Lazy is overkill, it doesn't need to be thread safe. Also add a test for this once you're done. |
So are you saying parse the name eagerly? Or just |
feb80f0
to
746f121
Compare
Lazy is fine but using |
@davidfowl How does it look now? |
@@ -149,7 +149,9 @@ public Task<IFormCollection> ReadFormAsync(CancellationToken cancellationToken) | |||
// Find the end | |||
await section.Body.DrainAsync(cancellationToken); | |||
|
|||
var file = new FormFile(_request.Body, section.BaseStreamOffset.Value, section.Body.Length) | |||
var name = HeaderUtilities.RemoveQuotes(contentDisposition.Name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can name ever be null here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems not
Much better! |
What about |
Go for it |
I think I change my mind on the lazy. Not worth it. Parse it out and just assign eagerly. |
cf081cd
to
91a98a8
Compare
Have you looked at the getters for Name and FileName in CDHV? Granted, it's not often you send files, and not very many of them, so it probably won't matter much. Want me to strip off that last commit then? 😄 |
7a3310e
to
f8bb6f6
Compare
|
||
public FormFile(Stream baseStream, long baseStreamOffset, long length) | ||
public FormFile(Stream baseStream, long baseStreamOffset, long length, ContentDispositionHeaderValue contentDisposition) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the quote removal on to the outside and just pass the name and file name. It's weird to have the header dependency in here (always was)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
5d1cd10
to
dfca389
Compare
return HeaderUtilities.RemoveQuotes(cd?.Name); | ||
foreach (var file in this) | ||
{ | ||
if (string.Equals(name, file.Name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ordinal or ignore case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I just kept what was already there. What would you expect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OrdinalIgnoreCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Ok this PR is good to go once the CI passes. Then we'll have to see what repos break. If I had to guess. MVC would be broken |
This commits also gets rid of the name closure in FormFileCollection by interating over the files in the collection instead of using Find and FindAll. Closes aspnet#352 and aspnet#499
0ef9636
to
c2e7618
Compare
Add Name and FileName to IFormFile
Fixes #499. These names should probably be cached somewhere. Anyone opposed to exposing a
Name
property onIFormFile
backed by aLazy<string>
?